package uri.model.mypage;

import java.util.List;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

import uri.model.BoardVO;
import uri.model.DiaryVO;

@Repository
public class MyPageDAOImpl implements MyPageDAO {
	@Resource(name="sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;

	@Override
	public List<DiaryVO> diaryList(DiaryVO dvo) {
		return sqlSessionTemplate.selectList("mypage.diaryList", dvo);
	}

	@Override
	public void writeDiary(DiaryVO dvo) {
		sqlSessionTemplate.insert("mypage.writeDiary", dvo);
	}

	@Override
	public void deleteDiary(DiaryVO dvo) {
		sqlSessionTemplate.delete("mypage.deleteDiary", dvo);
	}
	
	@Override
	public int totalContent(String loginId) {
		return sqlSessionTemplate.selectOne("mypage.totalContent",loginId);
	}

	@Override
	public DiaryVO updateDiaryForm(DiaryVO dvo) {
		return sqlSessionTemplate.selectOne("mypage.updateDiaryForm", dvo);
	}

	@Override
	public void updateDiary(DiaryVO dvo) {
		//System.out.println(dvo+"+++++++++++");
		sqlSessionTemplate.update("mypage.updateDiary", dvo);
		
	}

	@Override
	public List<DiaryVO> searchDiaryByDate(DiaryVO dvo) {
		return sqlSessionTemplate.selectList("mypage.searchDiaryByDate", dvo);
	}

	@Override
	public int searchTotalContent(DiaryVO dvo) {
		return sqlSessionTemplate.selectOne("mypage.searchTotalContent",dvo);
	}

	@Override
	public void writeDiaryNoFile(DiaryVO dvo) {
		sqlSessionTemplate.insert("mypage.writeDiaryNoFile", dvo);
	}

	@Override
	public void updateDiaryNoFile(DiaryVO dvo) {
		sqlSessionTemplate.update("mypage.updateDiaryNoFile", dvo);
		
	}

	@Override
	public List<DiaryVO> searchDiaryByContent(DiaryVO dvo) {
		return sqlSessionTemplate.selectList("mypage.searchDiaryByContent", dvo);
	}

	@Override
	public int searchDiaryTotalContent(DiaryVO dvo) {
		return sqlSessionTemplate.selectOne("mypage.searchDiaryTotalContent",dvo);
	}

	@Override
	public List<BoardVO> myListPub(BoardVO bvo) {
		return sqlSessionTemplate.selectList("mypage.myListPub", bvo);
	}

	@Override
	public List<DiaryVO> myListDiary(DiaryVO dvo) {
		return sqlSessionTemplate.selectList("mypage.myListDiary", dvo);
	}

	@Override
	public List<DiaryVO> searchDiaryByWord(String word) {
		return sqlSessionTemplate.selectList("mypage.searchDiaryByWord", word);
	}

	@Override
	public List<BoardVO> searchPublicByWord(String word) {
		return sqlSessionTemplate.selectList("mypage.searchPublicByWord", word);
	}

	@Override
	public List<BoardVO> searchCorrectionByWord(String word) {
		return sqlSessionTemplate.selectList("mypage.searchCorrectionByWord", word);
	}

	@Override
	public List<BoardVO> myListCorr(BoardVO bvo) {
		return sqlSessionTemplate.selectList("mypage.myListCorr", bvo);
	}
	
}
